﻿@using System.Data
@using ZoomLa.BLL.Helper
@using ZoomLa.Common
@model System.Data.DataTable
@{
    Layout = "~/Views/App/_layout.cshtml";
}
@functions{
    public string GetTypeStr(object status)
    {
        string html = "";
        switch (DataConverter.CLng(status))
        {
            case 0:
                html = "<span>等待生成</span>";
                break;
            default:
                html = "<span style='color:green;'>已生成</span>";
                break;
        }
        return html;
    }
    public string GetCodeImg(object imgurl,object id)
    {
        string url = imgurl.ToString();
        if (string.IsNullOrEmpty(url))
            return "<a href='CL?appid=" + id + "'>生成二维码</a>";
        else
            return "<img src='/Common/Common.ashx?url=" + url + "' class='codeimg'  />";
    }
}
@section head{
    <title>我的APP</title>
}
@section content{
<div style="margin-top:50px;">
    <table class="table table-striped table-bordered">
        @if (Model != null && Model.Rows.Count > 0)
        {
            <tr><th>名称</th><th>状态</th><th>类型</th><th>起始Url</th><th>二维码管理</th><th>创建时间</th><th>操作</th></tr>
            foreach (DataRow dr in Model.Rows)
            {
                <tr>
                    <td>@dr["APPName"]</td>
                    <td>@MvcHtmlString.Create(GetTypeStr(dr["MyStatus"]))</td>
                    <td>Android APP</td>
                    <td><a href="@StrHelper.UrlDeal(dr["FUrl"].ToString())" target="_blank">@dr["FUrl"]</a></td>
                    <td class="text-center">@MvcHtmlString.Create(GetCodeImg(dr["ImageUrl"],dr["ID"]))</td>
                    <td>@DataConverter.CDate(dr["AddTime"]).ToString("yyyy-MM-dd HH:mm:ss")</td>
                    <td>
                        @if(DataConverter.CLng(dr["MyStatus"])==1) { <a href="APPList_Down?ID=@dr["ID"]">下载</a> }
                        <a href="CL?appid=@dr["ID"]">二维码管理</a>
                    </td>
                </tr>
            }
        }
        else
        {
            <tr>
                <td colspan="7">尚无APP数据</td>
            </tr>
        }
    </table>
</div>
<div style="display:none;" id="preimg_div">
    <div class="text-center">
        <img id="precode_img" src="#" style="width:300px; height:300px;" />
    </div>
</div>
}
@section script{
<script type="text/javascript" src="/JS/Controls/ZL_Dialog.js"></script>
<script>
        var diag = new ZL_Dialog();
        $().ready(function () {
            $(".codeimg").click(function () {
                diag.title = "二维码扫描";
                diag.width = "none";
                diag.content = "preimg_div";
                diag.ShowModal();
                $("#precode_img").attr('src', $(this).attr('src'));
            });
        });
</script>
}